package com.erp.framework.model.delegate;

import java.util.Collection;

import com.erp.framework.SimpleConstants;
import com.erp.framework.model.dao.ServiceLocator;
import com.erp.framework.model.ejb.SimplePageEditStyleHome;
import com.erp.framework.model.ejb.SimplePageEditStyleRemote;
import com.erp.framework.util.logger.Logger;

public class SimplePageEditStyleDelegate extends SimpleBaseDelegate {
    private Object contr = null;

    protected Object getEjbManager() {

        if (this.contr == null) {
            try {
                SimplePageEditStyleHome home = null;
                home = (SimplePageEditStyleHome) ServiceLocator.getInstance().getHome(SimpleConstants.SIMPLE_PAGE_EDIT_STYLE_EJB,
                        SimplePageEditStyleHome.class);
                this.contr = home.create();
            } catch (java.lang.reflect.UndeclaredThrowableException ue) {
                Logger.logExceptions(this, ue);
                Logger.error(this, "getEjbManager(), error: " + ue.getUndeclaredThrowable());
            } catch (Exception e) {
                Logger.logExceptions(this, e);
            }
        }
        return this.contr;
    }

    public void updateBatch(Collection collection) throws Exception {
        try {
            ((SimplePageEditStyleRemote) getEjbManager()).updateBatch(collection);
        } catch (Exception e) {
            Logger.logExceptions(this, e);
            throw e;
        }
    }
}
